package com.aceitunaproject.mapdisplay.model.map;

/**
 * The directions a Unit can move to. Includes deltas for moving
 * to adjacent squares, which are required due to the isometric
 * map. Starting north and going clockwise.
*/
public enum Direction {
    N  ( 0, -2,  0, -2), 
    NE ( 1, -1,  0, -1), 
    E  ( 1,  0,  1,  0),
    SE ( 1,  1,  0,  1),
    S  ( 0,  2,  0,  2),
    SW ( 0,  1, -1,  1),
    W  (-1,  0, -1,  0),
    NW ( 0, -1, -1, -1);

    private int oddDX, oddDY, evenDX, evenDY;

    Direction(int oddDX, int oddDY, int evenDX, int evenDY) {
        this.oddDX = oddDX;
        this.oddDY = oddDY;
        this.evenDX = evenDX;
        this.evenDY = evenDY;
    }

    public int getOddDX() {
        return oddDX;
    }

    public int getOddDY() {
        return oddDY;
    }

    public int getEvenDX() {
        return evenDX;
    }

    public int getEvenDY() {
        return evenDY;
    }

    /**
     * Returns the reverse direction of the given direction.
     * 
     * @return The reverse direction of the given direction.
     */
    public Direction getReverseDirection() {
        switch (this) {
        case N:
            return S;
        case NE:
            return SW;
        case E:
            return W;
        case SE:
            return NW;
        case S:
            return N;
        case SW:
            return NE;
        case W:
            return E;
        case NW:
            return SE;
        default:
            return null;
        }
    }
}